//
//  HXSelectedPersonTableViewCell.m
//  KD
//
//  Created by ifly on 16/2/26.
//  Copyright © 2016年 ifly. All rights reserved.
//

#import "HXSelectedPersonTableViewCell.h"

@interface HXSelectedPersonTableViewCell()
@property (weak, nonatomic) IBOutlet UILabel *personLabel;
@property (weak, nonatomic) IBOutlet UILabel *msgLabel;
@property (weak, nonatomic) IBOutlet UIImageView *selectedImageView;
@end

@implementation HXSelectedPersonTableViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath data:(HXPersonSelectedListModel *)data
{
    UINib *nib = [UINib nibWithNibName:@"HXSelectedPersonTableViewCell" bundle:nil];
    [tableView registerNib:nib forCellReuseIdentifier:@"HXSelectedPersonTableViewCell"];
    HXSelectedPersonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HXSelectedPersonTableViewCell" forIndexPath:indexPath];
    cell.data = data;
    cell.msgLabel.text = data.CorpName;
    cell.personLabel.text = [NSString stringWithFormat:@"%@-%@",data.PerKindName,data.PersonName];
    cell.isSelected = NO;
    cell.selectedImageView.layer.borderWidth = 1;
    cell.selectedImageView.layer.borderColor =  HXCustomColor(74, 140, 247, 1).CGColor;
    if ([data.isSelected isEqualToString:@"no"]){
        cell.selectedImageView.image = nil;
    }else if ([data.isSelected isEqualToString:@"yes"]) {
        cell.selectedImageView.image = [UIImage imageNamed:@"blueTure"];
    }else{
        cell.selectedImageView.image = nil;
    }
    if (indexPath.row%2 == 0)cell.backgroundColor = [UIColor whiteColor];
    if (indexPath.row%2 != 0)cell.backgroundColor = HXCustomColor(239, 239, 244, 1);
    return cell;
}

//展示主管cell
+(instancetype)manageCellWithTableView:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath data:(HXSelectedManagePersonListModel *)data
{
    UINib *nib = [UINib nibWithNibName:@"HXSelectedPersonTableViewCell" bundle:nil];
    [tableView registerNib:nib forCellReuseIdentifier:@"HXSelectedPersonTableViewCell"];
    HXSelectedPersonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HXSelectedPersonTableViewCell" forIndexPath:indexPath];
    cell.manageData = data;
    cell.msgLabel.text = data.PersonName;
    cell.personLabel.text = [NSString stringWithFormat:@"%@-%@",data.DeptName,data.PersonName];
    cell.isSelected = NO;
    cell.selectedImageView.layer.borderWidth = 1;
    cell.selectedImageView.layer.borderColor =  HXCustomColor(74, 140, 247, 1).CGColor;
    if ([data.isSelected isEqualToString:@"no"]){
        cell.selectedImageView.image = nil;
    }else if ([data.isSelected isEqualToString:@"yes"]) {
        cell.selectedImageView.image = [UIImage imageNamed:@"blueTure"];
    }else{
        cell.selectedImageView.image = nil;
    }
    if (indexPath.row%2 == 0)cell.backgroundColor = [UIColor whiteColor];
    if (indexPath.row%2 != 0)cell.backgroundColor = HXCustomColor(239, 239, 244, 1);
    return cell;
}

- (void)setIsSelected:(BOOL)isSelected{
    _isSelected = isSelected;
    if (isSelected) {//选中
        self.selectedImageView.image = [UIImage imageNamed:@"blueTure"];
    }else{
        self.selectedImageView.image = nil;
    }
}
@end
